<template>
    <div class="member-add">
        <div class="member-add-card">
                <Col span="12">
                    <Card>
                        <p slot="title">
                            <a><Icon type="gear-a"></Icon>线下项目收款方法</a>
                        </p>
                        <div class="formCon">
                            <a class="title">{{title}}</a>
                            <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="80">
                                <FormItem label="用户名" prop="username">
                                    <Input v-model="formValidate.username" placeholder="请输入用户名"></Input>
                                </FormItem>
                                <FormItem label="电话" prop="phone">
                                    <Input v-model="formValidate.phone" placeholder="手机号"></Input>
                                </FormItem>
                                <FormItem label="金额" prop="money">
                                    <Input v-model="formValidate.money" placeholder="请输入金额"></Input>
                                </FormItem>
                                <FormItem label="备注" prop="beizhu">
                                    <Input v-model="formValidate.beizhu" placeholder="请输入备注"></Input>
                                </FormItem>
                            </Form>
                            <div class="button_style">
                                <Button type="primary" @click="sub" :loading="loading">提交</Button>
                            </div>
                        </div>
                    </Card>
                </Col>
            <!--提交-->
            <!--<div class="subCon">-->
                <!--<ButtonGroup>-->
                   <!---->
                    <!--&lt;!&ndash;<Button type="ghost" @click="reset">重置</Button>&ndash;&gt;-->
                <!--</ButtonGroup>-->
            <!--</div>-->
        </div>
    </div>
</template>
<script>
    export default {
        name:"offlinemoney-add",
        data(){
            const validateNum = (rule, value, callback) => {
                if (!value) {
                    return callback(new Error('请输入数字'));
                }
                // 模拟异步验证效果
                setTimeout(() => {
                    if (!Number.isInteger(value)) {
                        callback(new Error("请输入数字"));
                    } else {
                        callback();
                    }
                }, 1000);
            };
            return{
                formValidate:{
                    username:"",
                    phone:"",
                    money:"",
                    // shangji:"",
                    // tuanbei:"",
                    // dengji:"1",

                    beizhu:'',
                    birthday:'',
                },
                ruleValidate:{
                    username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
                    // sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
                    phone: [{ required: false, message: '请输入手机号码', trigger: 'blur' }],
                    money: [{ required: true, message: '请输入金额', trigger: 'blur' }],
                    beizhu: [{ required: false, message: '请输入备注', trigger: 'blur' }],
                    // shangji: [{ required: true, message: '请输入上级推手', trigger: 'blur' }],
                    // tuanbei: [{ required: true, validator: validateNum, trigger: 'blur' }],
                    // level: [{ required: true, message: '请选择等级', trigger: 'change' }],
                    // status: [{ required: true, message: '请选转状态', trigger: 'change' }],
                },
                imgUrl:"",
                loading:false,
                isEdit:false,
                uid:""
            }
        },
        mounted(){


        },
        methods:{
            getData(){


            },

            sub(){
                this.$refs.formValidate.validate((valid) => {
                    if (valid) {
                        this.sureSub()
                    }
                })
            },
            sureSub(){
                this.loading = true;

                this.getJsonData("User/addUserProject",{
                    username:this.formValidate.username,
                    phone:this.formValidate.phone,
                    money:this.formValidate.money,
                    beizhu:this.formValidate.beizhu,
                })
                    .then((res)=>{
                        this.loading = false
                        this.$Message.success(this.isEdit?'修改成功':'新增成功')
                        this.$router.back()
                    })
                    .catch((res)=>{
                        this.loading = false
                    })
            },
            reset(){
                this.imgUrl = ""
                this.$refs.formValidate.resetFields();
            }
        }
    }
</script>
<style lang="less">
    @import "./offlinemoney-add";
</style>